package com.yugao.fintech.antelope.system.model.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yugao.fintech.antelope.base.model.BasePlusPO;
import com.yugao.fintech.antelope.base.model.constants.ValidationCons;
import com.yugao.fintech.framework.core.annotations.FieldUnique;
import com.yugao.fintech.framework.core.annotations.FieldUniqueConfig;
import com.yugao.fintech.framework.core.enums.SqlConditionTypeEnum;
import com.yugao.fintech.framework.validation.group.UpdateGroup;
import lombok.*;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName("ram_module")
@FieldUniqueConfig(sqlCondition = SqlConditionTypeEnum.OR)
public class RamModule extends BasePlusPO {
    public static LambdaQueryWrapper<RamModule> lqw() {
        return Wrappers.lambdaQuery();
    }

    @TableId
    @NotNull(message = ValidationCons.NOT_EMPTY, groups = {UpdateGroup.class})
    private Long id;

    /**
     * 模块编码(一般为名称首字母即 {@link RamApiResource#getAction()} 第一段), 且不可改变
     *
     * @see RamApiResource
     */
    @NotEmpty(message = ValidationCons.NOT_EMPTY)
    @FieldUnique(message = "字典模块编码已存在")
    private String code;

    /**
     * 服务标识符, 这里指的是服务url的一级路径
     */
    private String serviceCode;

    /**
     * 模块名称
     */
    @NotEmpty(message = ValidationCons.NOT_EMPTY)
    private String name;
}
